//
//  MYXNIMSessionViewController.m
//  meiyinxiang
//
//  Created by 陈李飞 on 2017/11/1.
//  Copyright © 2017年 hbjApple. All rights reserved.
//聊天界面

#import "MYXNIMSessionViewController.h"
#import "NIMCustomLeftBarView.h"
#import "myfollowListModel.h"
#import "NIMKit.h"
#import "NIMMessageCellProtocol.h"
#import "NIMMessageModel.h"
#import "NIMKitUtil.h"
#import "NIMCustomLeftBarView.h"
#import "NIMBadgeView.h"
#import "UITableView+NIMScrollToBottom.h"
#import "NIMMessageMaker.h"
#import "NIMKitUIConfig.h"
#import "UIView+NIM.h"
#import "NIMSessionConfigurator.h"
#import "NIMKitInfoFetchOption.h"
#import "NIMSessionConfigur.h"
#import "NIMAvatarImageView.h"

@interface MYXNIMSessionViewController ()<NIMMediaManagerDelegate,NIMInputDelegate>
@property (nonatomic,strong)  NIMSessionConfigur *configurator;
@property (nonatomic,weak)    id<NIMSessionInteractor> interactor;
@end

@implementation MYXNIMSessionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = self.sessionTitle;
    NIMUser *user = [[NIMSDK sharedSDK].userManager userInfo:@"abc1"];
    GRLog(@"及时通信 头像---%@",user.userInfo.avatarUrl);
    /*
    NSString *account = [MYY_User readUserFromFile].accid;
    NSString *token   = [MYY_User readUserFromFile].imtoken;
    [[[NIMSDK sharedSDK] loginManager] login:account
                                       token:token
                                  completion:^(NSError *error) {
                                      NSLog(@"网易云---登录---error %@",error);
                                      
                                  }];*/
   
    
   
}
- (void)setupNav
{
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [btn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    btn.frame = (CGRect){CGPointZero, btn.currentImage.size};
    UIBarButtonItem *leftItem = [[UIBarButtonItem alloc] initWithCustomView:btn];
    self.navigationItem.leftBarButtonItem = leftItem;
    
}

-(void)back{
    [self.navigationController popViewControllerAnimated:YES];
}



- (void)changeLeftBarBadge:(NSInteger)unreadCount
{
    
}
- (void)setupConfigurator
{
    _configurator = [[NIMSessionConfigur alloc] init];
    [_configurator setup:self];
    
    BOOL needProximityMonitor = YES;
    if ([self.sessionConfig respondsToSelector:@selector(disableProximityMonitor)]) {
        needProximityMonitor = !self.sessionConfig.disableProximityMonitor;
    }
    [[NIMSDK sharedSDK].mediaManager setNeedProximityMonitor:needProximityMonitor];
}

#pragma mark - NIMSessionConfiguratorDelegate

- (void)didFetchMessageData
{
    [self uiCheckReceipt];
    [self.tableView reloadData];
    [self.tableView nim_scrollToBottom:NO];
}

- (void)didRefreshMessageData
{
    [self refreshSessionTitle:self.sessionTitle];
    [self refreshSessionSubTitle:self.sessionSubTitle];
    [self.tableView reloadData];
}
- (void)uiCheckReceipt
{
    if ([self shouldHandleReceipt]) {
        [self.interactor checkReceipt];
    }
}

- (BOOL)shouldHandleReceipt
{
    return [self.interactor shouldHandleReceipt];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
